<template>
  <div class="index-box layout">
    <a-layout id="components-layout-demo-custom-trigger">
        <a-layout-sider style="background-color: #ffffff;" v-model="collapsed" :trigger="null" collapsible>
          <div class="logo" style="    background-color: #1890FF !important;        padding-top: 17px;
    text-align: center;
    font-size: 18px;
    margin: 0px;
    height: 64px;"><span>Link数据库管理后台</span></div>
          <a-menu
          mode="inline"
          :selectedKeys="leftMenuKey"
          :default-open-keys="expandKeys"
          :default-selected-keys="expandKeys"
          v-if="showMenu"
          :style="{ height: '100vh', borderRight: 0 }"
        >
          <a-menu-item key="0" v-if="showIndex">
            <div @click="jumpPage({title:'数据看板',path:'/index',id:'-1'})">
              <a-icon type="bar-chart"  />{{collapsed?'':'数据看板'}}
            </div>
          </a-menu-item>
          <a-sub-menu :key="item.id" v-if="item.visible" v-for="(item,index) in menuShowArr">
            <span slot="title" @click.native.stop="jumpPage(item)"><a-icon :type="item.iconClass" />{{collapsed?'':item.title}}</span>
            <a-sub-menu @click.native.stop="jumpPage(second)" :key="second.id" v-for="second in item.children" :title="second.title" v-if="second.visible && 0 < second.children.length">
              <!-- <span slot="title" @click.stop="jumpPage(second.path)">{{collapsed?'':second.title}}</span> -->
              <a-menu-item v-if="third.visible" @click.native.stop="jumpPage(third)" :key="third.id" v-for="third in second.children">
                {{third.title}}
              </a-menu-item>
            </a-sub-menu>
            <a-menu-item v-show="second.visible" @click.native.stop="jumpPage(second)" :key="second.id" v-else>
              {{second.title}}
            </a-menu-item>
          </a-sub-menu>
          
        </a-menu>
        </a-layout-sider>
      <a-layout>
      <a-layout-header class="header" style="background: #fff; padding: 0">
        <a-icon
          style="color: #ffffff;"
          class="trigger"
          :type="collapsed ? 'menu-unfold' : 'menu-fold'"
          @click="() => (collapsed = !collapsed)"
        />
        <div class="user-wrapper">
          <a-dropdown>
            <span class="action action-full ant-dropdown-link user-dropdown-menu">
              <a-avatar class="avatar" size="small" src=""/>
              <span>欢迎您，{{userMessage.userName}}</span>
            </span>
            <a-menu slot="overlay" class="user-dropdown-menu-wrapper">
              <a-menu-item key="4" @click="updatePassword">
                <a-icon type="setting"/>
                <span>密码修改</span>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
          <span class="action">
            <a class="logout_title" href="javascript:;" @click="handleLogout">
              <a-icon type="logout"/>
              <span>&nbsp;退出登录</span>
            </a>
          </span>
        </div>
      </a-layout-header>
      <div class="tab-top">
        <!-- <span v-for="(item,index) in topTabsArr">{{item.title}}</span> -->
        <a-tabs v-model="activeKey" hide-add type="editable-card" @tabClick="tabClick" @edit="changeTab" v-if="topTabsArr && topTabsArr.length > 0">
        <a-tab-pane v-for="(pane,index) in topTabsArr"  :key="pane.id" :tab="pane.title" :closable="true">
        </a-tab-pane>
      </a-tabs>
      </div>
      
      <a-layout-content
        :style="{ margin: '24px 16px', background: '#fff', minHeight: '280px',maxHeight:'calc(100vh - 80px)' }">
        
        <transition name="fade" mode="out-in">
          <router-view></router-view>
        </transition>
      </a-layout-content>
    </a-layout>
    </a-layout>
    <a-modal v-model="changePasswordModal" title="修改密码" @ok="handleOk">
      <a-form :form="form">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="旧密码">
          <a-input type="password" placeholder="请输入" v-decorator="['oldPassword', {rules:[{required:true,message:'请输入'}]}]" />
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="新密码">
          <a-input type="password" placeholder="请输入" v-decorator="['newPassword', {rules:[{required:true,message:'请输入'}]}]" />
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="确认新密码">
          <a-input type="password" placeholder="请输入" v-decorator="['newPasswordConfirm', {rules:[{required:true,message:'请输入'}]}]" />
        </a-form-item>
      </a-form>
    </a-modal>
  </div>
</template>

<script>

export default {
  data() {
    return {
      form: this.$form.createForm(this),
      changePasswordModal:false,
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      showIndex:true,
      topTabsArr:[],
      expandKeys:[],
      showMenu:false,
      userMessage:{},
      collapsed: false,
      breadData:[{
        path:'/index',
        name:'首页',
      }],
      activeKey:'',
      leftMenuKey:[],
      menuShowArr: [{
          id: '1-1',
          title: '人脉数据',
          visible: true,
          path: '',
          iconClass:'apartment',
          children: [{
            id: '1-1-1',
            title: '人脉信息',
            visible: true,
            path: '/PersonalInfoList',
            children: []
          },{
            id: '1-1-2',
            title: '人脉关系',
            visible: true,
            path: '/PersonalRelationList',
            children: []
          }]
        },
        {
          id: '1-2',
          title: '企业数据',
          visible: true,
          path: '',
          iconClass:'block',
          children: [{
            id: '1-2-1',
            title: '基本信息',
            visible: true,
            path: '/CompanyInfoList',
            children: []
          },{
            id: '1-2-2',
            title: '公司人员',
            visible: true,
            path: '/CompanyStaffList',
            children: []
          },
          // {
          //   id: '1-2-2.1',
          //   title: '职务认证',
          //   visible: true,
          //   path: '/PositionVerify',
          //   children: []
          // },
          {
            id: '1-2-2.2',
            title: '投资机构',
            visible: true,
            path: '/Investor',
            children: []
          },
          {
            id: '1-2-3',
            title: '融资历程',
            visible: true,
            path: '/CompanyRefinanceList',
            children: []
          },{
            id: '1-2-4',
            title: '经营状况',
            visible: true,
            path: '/CompanyOperationList',
            children: []
          },{
            id: '1-2-5',
            title: '业务产品',
            visible: true,
            path: '/CompanyBusinessList',
            children: []
          },{
            id: '1-2-6',
            title: '新闻情报',
            visible: true,
            path: '/CompanyNewsList',
            children: []
          },{
            id: '1-2-7',
            title: '公司附件',
            visible: true,
            path: '/CompanyFilesList',
            children: []
          },
          
          // {
          //   id: '1-2-9',
          //   title: '合作信息',
          //   visible: true,
          //   path: '/CompanyCooprationList',
          //   children: []
          // },
          ]
        },
        {
        id: '-1',
        title: '互动数据',
        visible: true,
        path: '',
        iconClass:'swap',
        children: [
          {
            id: '1-2-8',
            title: '互动信息',
            visible: true,
            path: '/CompanyInteractiveList',
            children: []
          }
        ]},{
        id: '0',
        title: '商机数据',
        visible: true,
        path: '',
        iconClass:'money-collect',
        children: [
          {
            id: '1-2-9',
            title: '需求信息',
            visible: true,
            path: '/CompanyDemandList',
            children: []
          },
          {
            id: '1-2-10',
            title: '交易详情',
            visible: true,
            path: '/BusinessTrade',
            children: []
          }
        ]},
           {
          id: '3-1',
          title: '会员数据',
          visible: true,
          path: '',
          iconClass:'smile',
          children: [{
            id: '3-1-1',
            title: '会员信息',
            visible: true,
            path: '/VipUserList',
            children: []
          },{
            id: '3-1-2',
            title: '职业认证',
            visible: true,
            path: '/VipVerify',
            children: []
          },{
            id: '3-1-3',
            title: '活动信息',
            visible: true,
            path: '/ActivityList',
            children: []
          },{
            id: '3-1-4',
            title: '物品信息',
            visible: true,
            path: '/ProductList',
            children: []
          },{
            id: '3-1-5',
            title: '换物信息',
            visible: true,
            path: '/ChangeProductList',
            children: []
          }
          ,{
            id: '3-1-6',
            title: '服务商信息审核',
            visible: true,
            path: '/UserCard',
            children: []
          },{
            id: '3-1-7',
            title: '服务商申请',
            visible: true,
            path: '/UserSupplier',
            children: []
          },{
            id: '3-1-8',
            title: '行为日志',
            visible: true,
            path: '/UserOplog',
            children: []
          }
          ]
        },
      //   {
      //   id: '1',
      //   title: '主数据维护',
      //   visible: true,
      //   path: '',
      //   iconClass:'table',
      //   children: [{
      //     id: '1-1',
      //     title: '人脉数据',
      //     visible: true,
      //     path: '',
      //     children: [{
      //       id: '1-1-1',
      //       title: '人脉信息',
      //       visible: true,
      //       path: '/PersonalInfoList',
      //       children: []
      //     },{
      //       id: '1-1-2',
      //       title: '人脉关系',
      //       visible: true,
      //       path: '/PersonalRelationList',
      //       children: []
      //     }]
      //   },
      //    {
      //     id: '1-2',
      //     title: '企业数据',
      //     visible: true,
      //     path: '',
      //     children: [{
      //       id: '1-2-1',
      //       title: '基本信息',
      //       visible: true,
      //       path: '/CompanyInfoList',
      //       children: []
      //     },{
      //       id: '1-2-2',
      //       title: '公司人员',
      //       visible: true,
      //       path: '/CompanyStaffList',
      //       children: []
      //     },
      //     // {
      //     //   id: '1-2-2.1',
      //     //   title: '职务认证',
      //     //   visible: true,
      //     //   path: '/PositionVerify',
      //     //   children: []
      //     // },
      //     {
      //       id: '1-2-3',
      //       title: '融资历程',
      //       visible: true,
      //       path: '/CompanyRefinanceList',
      //       children: []
      //     },{
      //       id: '1-2-4',
      //       title: '经营状况',
      //       visible: true,
      //       path: '/CompanyOperationList',
      //       children: []
      //     },{
      //       id: '1-2-5',
      //       title: '业务产品',
      //       visible: true,
      //       path: '/CompanyBusinessList',
      //       children: []
      //     },{
      //       id: '1-2-6',
      //       title: '新闻情报',
      //       visible: true,
      //       path: '/CompanyNewsList',
      //       children: []
      //     },{
      //       id: '1-2-7',
      //       title: '公司附件',
      //       visible: true,
      //       path: '/CompanyFilesList',
      //       children: []
      //     },
          
      //     // {
      //     //   id: '1-2-9',
      //     //   title: '合作信息',
      //     //   visible: true,
      //     //   path: '/CompanyCooprationList',
      //     //   children: []
      //     // },
      //     ]
      //   },
      //    {
      //     id: '3-1',
      //     title: '会员数据',
      //     visible: true,
      //     path: '',
      //     children: [{
      //       id: '3-1-1',
      //       title: '会员信息',
      //       visible: true,
      //       path: '/VipUserList',
      //       children: []
      //     },{
      //       id: '3-1-2',
      //       title: '职业认证',
      //       visible: true,
      //       path: '/VipVerify',
      //       children: []
      //     },{
      //       id: '3-1-3',
      //       title: '活动信息',
      //       visible: true,
      //       path: '/ActivityList',
      //       children: []
      //     },{
      //       id: '3-1-4',
      //       title: '物品信息',
      //       visible: true,
      //       path: '/ProductList',
      //       children: []
      //     },{
      //       id: '3-1-5',
      //       title: '换物信息',
      //       visible: true,
      //       path: '/ChangeProductList',
      //       children: []
      //     }]
      //   },]
      // },
      {
        id: '2',
        title: '辅数据维护',
        visible: true,
        path:'',
        iconClass:'file-search',
        children: [{
            id: '2-0',
            title: '产业园区信息',
            visible: true,
            path: '/BaseIndustrialPark',
            children: []
          },{
            id: '2-1',
            title: '园区信息',
            visible: true,
            path: '/BaseHighteckparkList',
            children: []
          },{
            id: '2-2',
            title: '省',
            visible: true,
            path: '/BaseRegionList',
            children: []
          },{
            id: '2-3',
            title: '城市',
            visible: true,
            path: '/BaseRegionCityList',
            children: []
          },{
            id: '2-4',
            title: '区县',
            visible: true,
            path: '/BaseRegionDistrictList',
            children: []
          },{
            id: '2-5',
            title: '行业信息',
            visible: true,
            path: '/BaseIndustryList',
            children: []
          },{
            id: '2-6',
            title: '行业标签',
            visible: true,
            path: '/BaseIndustrytagList',
            children: []
          },{
            id: '2-7',
            title: '子需求类型',
            visible: true,
            path: '/subDemandTypeList',
            children: []
          },{
            id: '2-8',
            title: '基础代码',
            visible: true,
            path: '/BaseInfoList',
            children: []
          }]
      },{
        id: '3',
        title: 'Linker员工',
        visible: true,
        path:'',
        iconClass:'user',
        username:'',
        children: [{
            id: '3-1',
            title: '员工信息',
            visible: true,
            path: '/userList',
            children: []
          }]
      }]
    }
  },
  created() {
    //移除首页加载动画
    this.getPerson();
    if(document.getElementById('Loading')) {
      document.body.removeChild(document.getElementById('Loading'))
    }
  },
  watch: {
    $route: {
      handler: function(val, oldVal){
        this.getBreadcrumb(val)
      },
      // 深度观察监听
      deep: true
    }
  },
  
  mounted() {
    if(sessionStorage.getItem('activeSub')){
      this.leftMenuKey.push(sessionStorage.getItem('activeSub'));
      // this.showMenu = false;
      // this.$nextTick(()=>{
      //   this.showMenu = true;
      // })
    }
    this.topTabsArr = sessionStorage.getItem('topTabsArr')?JSON.parse(sessionStorage.getItem('topTabsArr')):[];
    
    this.topTabsArr.forEach((e,index)=>{
        if(e.path == this.$route.path){
          this.activeKey = e.id;
        }
    })
    console.log('ggg',this.leftMenuKey)
    
  },
  methods: {
    handleOk(){
        let userId = localStorage.getItem('userInfo')?JSON.parse(localStorage.getItem('userInfo')).userId:'';
        if(!userId){
          // this.$message.error('尚未登录或登录过期');
          return false;
        }
        const that = this;
        // 触发表单验证
        this.form.validateFields((err, values) => {
          if (!err) {
            let formData = Object.assign({}, values);

            if(formData.newPasswordConfirm !== formData.newPassword){
              this.$message.error('两次新密码不一致');
              return false;
            }

            formData.userId = userId;
            let httpurl = '/auth/changePassword';
            this.$http.postAction(httpurl,formData).then((res)=>{
              if(res.status == 1){
                that.$message.success(res.message);
                that.changePasswordModal = false;
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              // that.close();
            })
          }
        })
      },
    updatePassword(){
      this.changePasswordModal = true;
      // let username = this.userInfo().username
      // this.$refs.userPassword.show(username)
    },
    getBreadcrumb(to){
      this.leftMenuKey = [];
      this.menuShowArr.forEach((e)=>{
        if(e.path == to.path){
          this.leftMenuKey.push(e.id);
          this.expandKeys.push(e.id);
        }else{
          e.children.map((second,secIndex)=>{
            if(second.path == to.path){
              this.leftMenuKey.push(second.id);
              this.expandKeys.push(e.id);
            }else{
              second.children.map((third,thiIndex)=>{
                if(third.path == to.path){
                  this.leftMenuKey.push(third.id);
                  this.expandKeys.push(second.id);
                  this.expandKeys.push(e.id);
                }
              })
            }
          })
        }
      })
      if(0 == this.leftMenuKey.length){
        this.leftMenuKey = ['0'];
      }
      // this.showMenu = false;
      // this.$nextTick(()=>{
      //   this.showMenu = true;
      // })
      sessionStorage.setItem('activeSub',this.leftMenuKey[0])
      console.log('this.$route.matched', this.$route.matched)
    },
    tabClick(key){
      let index = 0;
      this.topTabsArr.forEach((e,eIndex)=>{
        if(e.id == key){
          index = eIndex;
        }
      })
      this.jumpPage(this.topTabsArr[index]);
    },
    changeTab(key,action){
      let index = 0;
      this.topTabsArr.forEach((e,eIndex)=>{
        if(e.id == key){
          index = eIndex;
        }
      })
      if(action == 'remove'){
        this.topTabsArr.splice(index,1)
      }
      sessionStorage.setItem('topTabsArr',JSON.stringify(this.topTabsArr))
      console.log('ggggg',this.topTabsArr)
    },
    jumpPage(data){
      if(!data.path){
        return false;
      }
      
      let topTabsArr = sessionStorage.getItem('topTabsArr')?JSON.parse(sessionStorage.getItem('topTabsArr')):[];
      if(!topTabsArr.some((e)=>{return e.path == data.path})){
        if(topTabsArr.length == 10){
          this.$message.error('最多可开10个窗口，请先关闭无用窗口')
          return false;
        }
        topTabsArr.push(data);
      }
      this.activeKey = data.id;
      console.log('sss',topTabsArr)
      this.topTabsArr = topTabsArr;
      sessionStorage.setItem('topTabsArr',JSON.stringify(topTabsArr))
      this.$router.push(data.path)
    },
    getPerson(){
      this.userMessage = localStorage.getItem('userInfo')?JSON.parse(localStorage.getItem('userInfo')):{};
      
      let id = this.userMessage.userId;
      let param = {conditions:[]};
      param.conditions = [{
        "field":"Id",
        "operator":"=",
        "value":id
      }]
      let isLogin = sessionStorage.getItem('isLogin');
      this.$http.postAction('/user/queryRows',param).then((res) => {
        this.showMenu = true;
          if (res.status == 1 && res.data && res.data.rows && 0 < res.data.rows.length) {
              let linkerStaff = res.data.rows[0];
              this.showIndex = true;
              //Linker：用户角色的权限要设置下，采编记者、编辑运营、商务经理、数据分析、综合管理这些用户角色的权限设定为：能操作“主数据维护”下面的“人脉数据”和“企业数据”；后台运营的权限设定为：能操作“主数据维护”下面的所有功能
              if(linkerStaff.UserRole == '467050395466727424' || linkerStaff.UserRole == '548156067960324096' || linkerStaff.UserRole == '548155898787266560' || linkerStaff.UserRole == '467050434893185024' || linkerStaff.UserRole == '467050306853666816'){
                //编辑
                //Linker：用户角色的权限要设置下，采编记者、编辑运营、商务经理、数据分析、综合管理这些用户角色的权限设定为：能操作“主数据维护”下面的“人脉数据”和“企业数据”；后台运营的权限设定为：能操作“主数据维护”下面的所有功能
                // this.showIndex = false;
                this.menuShowArr.map(e=>{
                    if(e.title !== '人脉数据' && e.title !== '企业数据' && e.title !== '商机数据' && e.title !== '互动数据'){
                      e.visible = false;
                    }
                    // e.children.map(sec=>{
                    //   if(sec.title !== '企业数据' && sec.title !== '人脉数据'){
                    //     sec.visible = false;
                    //   }
                    // })
                  })
                if(isLogin){
                  this.$router.push('/index');
                }
              }else if(linkerStaff.UserRole == '548156237502480384'){
                //后台运营
                //Linker：用户角色的权限要设置下，采编记者、编辑运营、商务经理、数据分析、综合管理这些用户角色的权限设定为：能操作“主数据维护”下面的“人脉数据”和“企业数据”；后台运营的权限设定为：能操作“主数据维护”下面的所有功能
                // this.showIndex = false;
                this.menuShowArr.map(e=>{
                    if(e.title !== '人脉数据' && e.title !== '企业数据' && e.title !== '会员数据' && e.title !== '主数据维护' && e.title !== '商机数据' && e.title !== '互动数据'){
                      e.visible = false;
                    }
                  })
                if(isLogin){
                  this.$router.push('/index');
                }
              }
              let to = {
                path:this.$route.path
              }
              this.getBreadcrumb(to)
              console.log('this.menuShowArr',this.menuShowArr);
              sessionStorage.setItem('isLogin','');
          }
      })
      // this.$http.getUser({selectFields:[],conditions:[{
      //         "field":"Name",
      //         "operator":"=",
      //         "value":this.username
      //       }]}).then(res => {
      //     if(res.status == 1){
      //       this.userMessage = res.data.rows.length>0?res.data.rows[0]:{Name:'admin'}
      //     }else{
            
      //     }
      //   }, error => {
          
      //   })
    },
    handleLogout() {
      const that = this

      this.$confirm({
        title: '提示',
        content: '真的要注销登录吗 ?',
        okText:"确定",
        cancelText:'取消',
        onOk() {
          return that.loginOut().then(() => {
              window.location.href="/";
            //window.location.reload()
          }).catch(err => {
            that.$message.error({
              title: '错误',
              description: err.message
            })
          })
        },
        onCancel() {
        },
      });
    },
    
    add0(m){
      return m < 10 ? '0' + m: m
    },
    formatTime(timestamp){
      var time = new Date(timestamp)    //先将时间戳转为Date对象，然后才能使用Date的方法
      var year = time.getFullYear(),
          month = time.getMonth() + 1 ,  //月份是从0开始的
          day = time.getDate(),
          hour = time.getHours(),
          minute = time.getMinutes(),
          second = time.getSeconds()
          //add0()方法在后面定义
      return  year+'-'+this.add0(month)+'-'+ this.add0(day)+' '+this.add0(hour)+':'+this.add0(minute) +':'+this.add0(second)
    },
    dateFormat(timestamp){
      var time = new Date(timestamp)    //先将时间戳转为Date对象，然后才能使用Date的方法
      var year = time.getFullYear(),
          month = time.getMonth() + 1 ,  //月份是从0开始的
          day = time.getDate(),
          hour = time.getHours(),
          minute = time.getMinutes(),
          second = time.getSeconds()
          //add0()方法在后面定义
      return  year+'-'+this.add0(month)+'-'+ this.add0(day)+' '+this.add0(hour)+':'+this.add0(minute) 
    },
    formatZTime(createTime){
      if(!createTime){
        return '';
      }
      try{
        createTime = Date.parse(new Date(createTime.split('.')[0].replace('T'," ")))+1000*3600*8;
        createTime = this.dateFormat(createTime)
        return createTime
      }catch(e){
        return '';
      }
      
    },
    loginOut(){
      var p = new Promise((resolve,reject)=>{
        localStorage.setItem('token','')
        resolve()
        // this.$http.loginOut().then(res => {
        //   if(res !== 'error'){
        //     localStorage.setItem('token','')
        //     resolve()
        //   }else{
        //     reject()
        //   }
        // }, error => {
        //   reject()
        // })
      })
      return p
    },
    showLoginOutDiv(){
      this.showLoginOut = !this.showLoginOut
    },
    changeBread(){
      console.log('ggg',this.$route)
      let to = {
        path:this.$route.path
      }
      this.breadData = [{
              path:'/index',
              name:'首页',
            }]
      switch(to.path){
          case '/fund-management':
            this.breadData.push({
              path:'/fund-management',
              name:'投资主体',
            })
          break;
          case '/detail':
            this.breadData.push({
              path:'/fund-management',
              name:'投资主体',
            })
            this.breadData.push({
              path:'/detail',
              name:'投资主体详情',
            })
          break;
          case '/lp-detail':
            this.breadData.push({
              path:'/fund',
              name:'投资主体',
            })
            this.breadData.push({
              path:'/detail',
              name:'投资主体详情',
            })
            this.breadData.push({
              path:'/lp-detail',
              name:'LP详情',
            })
          break;
          case '/schedule-management':
            this.breadData.push({
              path:'/schedule-management',
              name:'日程管理',
            })
          break;
          case '/project':
            this.breadData.push({
              path:'/project',
              name:'项目管理',
            })
          break;
          case '/project-detail':
            this.breadData.push({
              path:'/project',
              name:'项目管理',
            })
            this.breadData.push({
              path:'/project-detail',
              name:'项目详情',
            })
          break;
          case '/invmanagement':
            this.breadData.push({
              path:'/invmanagement',
              name:'投后管理',
            })
          break;
          case '/invmanagement-detail':
            this.breadData.push({
              path:'/invmanagement',
              name:'投后管理',
            })
            this.breadData.push({
              path:'/invmanagement-detail',
              name:'投后详情',
            })
          break;
          case '/pre-investment':
            this.breadData.push({
              path:'/invmanagement',
              name:'投后管理',
            })
            this.breadData.push({
              path:'/pre-invmanagement',
              name:'投前详情',
            })
          break;
          case '/financialState':
            this.breadData.push({
              path:'/invmanagement',
              name:'投后管理',
            })
            this.breadData.push({
              path:'/invmanagement-detail',
              name:'投后详情',
            })
            this.breadData.push({
              path:'/financialState',
              name:'财务报表',
            })
          break;
          case '/resource':
            this.breadData.push({
              path:'/resource',
              name:'资源管理',
            })
          break;
          case '/resource-detail':
            this.breadData.push({
              path:'/resource',
              name:'资源管理',
            })
            this.breadData.push({
              path:'/resource-detail',
              name:'资源详情',
            })
          break;
          case '/report':
             this.breadData.push({
              path:'/report',
              name:'报告管理',
            })
          break;
          case '/system':
            this.breadData.push({
              path:'/system',
              name:'系统管理',
            })
          break;
          case '/personal':
            this.breadData.push({
              path:'/personal',
              name:'个人中心',
            })
          break;
      }
      if(to.path == '/index'){
        this.menuShowArr.map((e,index)=>{
          if('/index' == e.path){
            e.active = true;
          }else{
            e.active = false;
          }
        })
      }
      sessionStorage.setItem('bread',JSON.stringify(this.breadData))
    },
    toPage(item){
      this.menuShowArr.map((e,index)=>{
        e.active = false;
      })
      item.active = true;
      
      console.log('vv',this.menuShowArr)
      if(item.path){
        this.$router.push(item.path)
      }
    },
    onClickLogout() {
      this.loading = true
      // 登出操作
      this.$axios({
        method: "POST",
        url: url_g + '/auth/logout'
      }).then((res) => {
        let data = res.data
        if(data.success) {
          sessionStorage.removeItem('permissionList')
          this.$router.push('/')
        } else {
          this.$message.error(data.message || '操作失败')
        }
        this.loading = false
      }).catch((e)=>{
        this.loading = false
        alert(e)
      })
    },
    getUserInfo() {
      // 获取用户信息
      this.$axios({
        method: "GET",
        url: url_g + '/auth/getLoginUser'
      }).then((res) => {
        let data = res.data
        if(data.success) {
          this.name = data.data.name
          // 获取侧边栏信息
          // ['1', '2', '3']
          let permissionList = data.data.permissionList
          for(let i = 0, len = permissionList.length; i < len; i ++) {
            this.menuShowArr[parseInt(permissionList[i]) - 1].visible = true
          }
        } else {
          this.$message.error(data.message || '操作失败')
          this.$router.push('/')
        }
      }).catch((e)=>{
        alert(e)
      })
    },
    jumpToPersonal() {
      this.$router.push({path:'/personal'})
    }
  }
}
</script>

<style>
p {
  margin: 0;
}

  .header{
    color: #ffffff;
  }
     .header .user-wrapper,  .top-nav-header-index .user-wrapper {
      float: right;
      height: 100%;
  }
   .header .user-wrapper .action,  .top-nav-header-index .user-wrapper .action {
    cursor: pointer;
    padding: 0 14px;
    display: inline-block;
    -webkit-transition: all .3s;
    transition: all .3s;
    height: 70%;
    line-height: 46px;
    margin-right:15px;
}
 .header .user-wrapper .action:hover,  .top-nav-header-index .user-wrapper .action:hover {
    background: hsla(0,0%,100%,.3);
}
.logout_title{
  color: #ffffff;

}
.logout_title i{
  color: #ffffff;
}
.layout .header .user-wrapper .action .avatar, .layout .top-nav-header-index .user-wrapper .action .avatar {
    margin: 20px 10px 20px 0;
    color: #1890ff;
    background: hsla(0,0%,100%,.85);
    vertical-align: middle;
}
.layout .header .user-wrapper .action.action-full, .layout .top-nav-header-index .user-wrapper .action.action-full {
    height: 100%;
}
.tab-top{
  background-color:#ffffff;
  width:100%;
  height:52px;
  border-left: solid 1px #cccccc;
  border-bottom: solid 1px #cccccc;
  padding: 0 20px;
  padding-top:4px;
}
.tab-top span{
  height:40px;
  line-height:40px;
  margin-right:10px;
  padding: 0px 24px;
}
.tab-top span.active{
  color: #1890FF;
}
</style>
<style>
#components-layout-demo-custom-trigger .trigger {
  font-size: 18px;
  line-height: 64px;
  padding: 0 24px;
  cursor: pointer;
  transition: color 0.3s;
}

#components-layout-demo-custom-trigger .trigger:hover {
  color: #1890ff;
}
#components-layout-demo-custom-trigger .ant-layout-header{
  background-color: #1890FF !important;
}
#components-layout-demo-custom-trigger .ant-layout-sider-dark{
  background-color: #1890FF;
}
#components-layout-demo-custom-trigger .logo {
  height: 32px;
  background-color: #1890FF;
  margin: 16px;
  color: #ffffff;
  font-size:18px;
}
</style>